﻿@using CubicFWNet.Data.Models
@using CubicFWNet.Data.ViewModal
@model CubicFWNet.Data.Models.Order
@{
    //var product = ViewBag.Product as Product;
    var invoice = ViewBag.Invoice as Invoice;
    var sc = ViewBag.SendCar as SendCar;
    var exp = ViewBag.ExpressOrder as ExpressOrder;
    var customerShortName = ViewBag.CustomerShortName;
    var order = ViewBag.Order as Order;
}
<section class="content-header">
    <h1>
        发货通知单
    </h1>
    <ol class="breadcrumb">
        <li><a href="javascript:void(0);"><i class="fa fa-dashboard"></i>@Resources.Global.PageTitle</a></li>
        <li><a href="@Url.Action("Index", "Home")">首页</a></li>
        <li class="active"><a href="@Url.Action("InvoiceQuery", "Order")">发货通知单</a></li>
    </ol>
</section>
<section class="content">
    <div class="box box-solid">
        <!-- /.box-header -->
        <div class="box-body">
            <div class="row">
                @if (Model != null && invoice != null)
                {
                    <form class="form-horizontal" id="frmedit" action="@Url.Action("AddInvoice", "Order")" method="post">
                        <input type="hidden" id="OrderId" name="OrderId" value="@Model.Id" />
                        <input type="hidden" id="InvoiceNumber" name="InvoiceNumber" value="@invoice.Number" />
                        <input type="hidden" id="SendPeople" name="SendPeople" value="@invoice.SendPeople" />
                        <div class="box-body" id="divPrint">
                            <div id="json-content" class="col-md-12 ">
                                <div style="text-align:center;height:50px; font-weight:bold; font-size:18px">发货通知单</div>
                                <div style="line-height:30px;">
                                    <div style="width:48%; display:inline-block">
                                        收货单位：@invoice.TakeCompany <br />
                                        发货单位：永嘉信<br />
                                        发货日期：@invoice.DliveryTime.Year 年 @invoice.DliveryTime.Month 月 @invoice.DliveryTime.Day 日 <br />
                                        @*收货人：@invoice.ReceivePeople <br />*@
                                        订单号：@order.CusNumber<br />
                                        备注：@invoice.Memo
                                    </div>
                                    <div style="width:48%; float:right;display:inline-block">
                                        发货单编号：@invoice.Number<br />
                                        填单日期：@invoice.CreateTime.Value.Year 年 @invoice.CreateTime.Value.Month 月 @invoice.CreateTime.Value.Day 日 <br />
                                        预计到货日期：@invoice.ReceivedTime.Year 年 @invoice.ReceivedTime.Month 月 @invoice.ReceivedTime.Day 日 <br />
                                        发货人 ：@invoice.SendPeople <br />
                                        送货要求：@invoice.DliveryDemand <br />

                                    </div>
                                </div>
                                <input type="hidden" id="modalData" value="@invoice.Data" readonly="readonly">
                                <table class="footable table table-stripped table-bordered table-hover" id="footable">
                                    <thead>
                                        <tr>
                                            <th data-sort-ignore="true">
                                                品名
                                            </th>
                                            @*<th data-sort-ignore="true">
                                                    订单号
                                                </th>
                                                <th data-sort-ignore="true">
                                                    发货人
                                                </th>*@
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                尺寸宽-mm
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                尺寸长-mm
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true">
                                                基本单位
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true" class="col-md-2">
                                                数量
                                            </th>
                                            <th data-hide="phone,table" data-sort-ignore="true" class="col-md-2">
                                                价格
                                            </th>
                                            <th data-hide="phone" data-sort-ignore="true" class="col-md-2">
                                                金额
                                            </th>
                                        </tr>
                                    </thead>
                                    <tbody id="data-content"></tbody>
                                </table>
                                <div style="width:60%; display:inline-block">
                                    制表人：@invoice.CreatorName<br />
                                    打印人：@ViewBag.UserName<br />
                                    制表日期：@DateTime.Now.Year 年 @DateTime.Now.Month 月 @DateTime.Now.Day 日
                                </div>
                                <div style="width:35%; display:inline-block">
                                    收货人签收： <br /><br />
                                    @if (invoice.Type == 1 && sc != null)
                                    {
                                        <div id="car">
                                            派车：@sc.Demand
                                        </div>
                                    }
                                    @if (invoice.Type == 2 && exp != null)
                                    {
                                        <div id="express">
                                            快递名称：@exp.ExpTypeName &nbsp;&nbsp;&nbsp; 快递编号：@exp.ExpNumber
                                        </div>
                                    }
                                </div>
                            </div>

                            
                        </div>
                        <div class="box-footer" style="width: 80%; margin-left: 20px;">
                            <span class="btn btn-primary submitbtn" id="print" onclick="print()">打印</span>
                        </div>
                    </form>
                }
            </div>
        </div>
    </div>
</section>

<div id="loadingPage" style="display: none;">
    <div class="loading-shade"></div>
    <div class="loading-content" onclick="$.loading(false)">数据加载中，请稍后…</div>
</div>

@section Scripts{
    <script src="~/Scripts/jquery.jqprint-0.3.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            var yy = document.getElementById("modalData").value;
            if (yy != "") {
                var data = JSON.parse(document.getElementById("modalData").value);
                var $content = $('#data-content');
                //var $content1 = $('#data-content1');
                //var number = $("#InvoiceNumber").val();
                //var sendpeo = $("#SendPeople").val();
                var html = "";
                console.log(data);
                for (var i = 0; i < data.length; i++) {
                    if (!isNaN(data[i].ProductAmount)) {
                        var amo = data[i].ProductAmount / 1;
                        if (amo > 0) {
                            html += "<tr class='tr'>";
                            html += "<td>" + data[i].ProductName + "</td>";
                            /*html += "<td>" + number + "</td>";
                            html += "<td>" + sendpeo + "</td>";*/
                            html += "<td>" + data[i].ProductSizeWidth + "</td>";
                            html += "<td>" + data[i].ProductSizeLenth + "</td>";
                            html += "<td>" + data[i].ProductUnit + "</td>";
                            html += "<td>" + amo.toFixed(0) + "</td>";
                            html += "<td>" + data[i].ProductPrice + "</td>";
                            html += "<td>" + data[i].TotalMoney + "</td>";
                            html += "</tr>";
                        }
                    }
                }
                $content.append(html);
                //$content1.append(html);
            }
            $('#footable').footable();
        });


        function print() {
            $("#divPrint").jqprint();
        }

    </script>
}